/*TOOLTIP SCRIPT WAS EDITED BY FATANGEL26@GMAIL.COM - NGUYỄN BẢO TRUNG*/


$(document).ready(function(){

	isdock    = false;
	statusTip = "Nhấn chuột phải để sticky tooltip !";

	$(".tip_trigger").mouseenter(function(){
		tip = $(this).find('.tip');
		tip.show();
	}).mouseleave(function(){
		tip.hide();
		isdock = false;
		tip.find('.tip_status').text(statusTip);
	}).mousemove(function(e){
		if(!isdock)
		{
			var mousex = e.pageX + 20;
			var mousey = e.pageY + -30;
			var tipWidth = tip.width();
			var tipHeight = tip.height();

			mousex = (mousex + tipWidth > $(document).scrollLeft() + $(window).width()) ? mousex-tipWidth-(20*2) : mousex
			mousey = (mousey + tipHeight > $(document).scrollTop() + $(window).height()) ? $(document).scrollTop()+$(window).height()-tipHeight-10 : mousey

			tip.css({  top: mousey, left: mousex });
		}
	}).bind("contextmenu", function(e){
		if(e.button == 2)
		{
			//count ++;
			//if(count == 1)
				isdock = true;
				tip.find('.tip_status').text('');
			/*else
			{
				isdock = false;
				count  = 0;
			}*/

			return false;
		}
	}).bind("click", function(e){
		e.stopPropagation();
	})
});